
/*
'===============================================================================
'  Generated From - CSharp_dOOdads_BusinessEntity.vbgen
' 
'  ** IMPORTANT  ** 
'  How to Generate your stored procedures:
' 
'  SQL        = SQL_StoredProcs.vbgen
'  ACCESS     = Access_StoredProcs.vbgen
'  ORACLE     = Oracle_StoredProcs.vbgen
'  FIREBIRD   = FirebirdStoredProcs.vbgen
'  POSTGRESQL = PostgreSQL_StoredProcs.vbgen
'
'  The supporting base class SqlClientEntity is in the Architecture directory in "dOOdads".
'  
'  This object is 'abstract' which means you need to inherit from it to be able
'  to instantiate it.  This is very easilly done. You can override properties and
'  methods in your derived class, this allows you to regenerate this class at any
'  time and not worry about overwriting custom code. 
'
'  NEVER EDIT THIS FILE.
'
'  public class YourObject :  _YourObject
'  {
'
'  }
'
'===============================================================================
*/

// Generated by MyGeneration Version # (1.3.0.3)

using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Collections.Specialized;
using MyGeneration.dOOdads;

namespace DataAccess.Modules.Entity.Security
{
	public abstract class _Person : SqlClientEntity
	{
		public _Person()
		{
			this.QuerySource = "Person";
			this.MappingName = "Person";

		}	

		//=================================================================
		//  public Overrides void AddNew()
		//=================================================================
		//
		//=================================================================
		public override void AddNew()
		{
			base.AddNew();
			
		}
		
		
		public override void FlushData()
		{
			this._whereClause = null;
			this._aggregateClause = null;
			base.FlushData();
		}
		
		//=================================================================
		//  	public Function LoadAll() As Boolean
		//=================================================================
		//  Loads all of the records in the database, and sets the currentRow to the first row
		//=================================================================
		public bool LoadAll() 
		{
			ListDictionary parameters = null;
			
			return base.LoadFromSql("[" + this.SchemaStoredProcedure + "proc_PersonLoadAll]", parameters);
		}
	
		//=================================================================
		// public Overridable Function LoadByPrimaryKey()  As Boolean
		//=================================================================
		//  Loads a single row of via the primary key
		//=================================================================
		public virtual bool LoadByPrimaryKey(int IdPerson)
		{
			ListDictionary parameters = new ListDictionary();
			parameters.Add(Parameters.IdPerson, IdPerson);

		
			return base.LoadFromSql("[" + this.SchemaStoredProcedure + "proc_PersonLoadByPrimaryKey]", parameters);
		}
		
		#region Parameters
		protected class Parameters
		{
			
			public static SqlParameter IdPerson
			{
				get
				{
					return new SqlParameter("@IdPerson", SqlDbType.Int, 0);
				}
			}
			
			public static SqlParameter Name
			{
				get
				{
					return new SqlParameter("@Name", SqlDbType.VarChar, 100);
				}
			}
			
			public static SqlParameter Lastname
			{
				get
				{
					return new SqlParameter("@Lastname", SqlDbType.VarChar, 100);
				}
			}
			
			public static SqlParameter IdIDCard
			{
				get
				{
					return new SqlParameter("@IdIDCard", SqlDbType.Int, 0);
				}
			}
			
			public static SqlParameter Photo
			{
				get
				{
					return new SqlParameter("@Photo", SqlDbType.Image, 2147483647);
				}
			}
			
			public static SqlParameter Notes
			{
				get
				{
					return new SqlParameter("@Notes", SqlDbType.VarChar, 2147483647);
				}
			}
			
			public static SqlParameter IdStatusCRUD
			{
				get
				{
					return new SqlParameter("@IdStatusCRUD", SqlDbType.Int, 0);
				}
			}
			
		}
		#endregion		
	
		#region ColumnNames
		public class ColumnNames
		{  
            public const string IdPerson = "IdPerson";
            public const string Name = "Name";
            public const string Lastname = "Lastname";
            public const string IdIDCard = "IdIDCard";
            public const string Photo = "Photo";
            public const string Notes = "Notes";
            public const string IdStatusCRUD = "IdStatusCRUD";

			static public string ToPropertyName(string columnName)
			{
				if(ht == null)
				{
					ht = new Hashtable();
					
					ht[IdPerson] = _Person.PropertyNames.IdPerson;
					ht[Name] = _Person.PropertyNames.Name;
					ht[Lastname] = _Person.PropertyNames.Lastname;
					ht[IdIDCard] = _Person.PropertyNames.IdIDCard;
					ht[Photo] = _Person.PropertyNames.Photo;
					ht[Notes] = _Person.PropertyNames.Notes;
					ht[IdStatusCRUD] = _Person.PropertyNames.IdStatusCRUD;

				}
				return (string)ht[columnName];
			}

			static private Hashtable ht = null;			 
		}
		#endregion
		
		#region PropertyNames
		public class PropertyNames
		{  
            public const string IdPerson = "IdPerson";
            public const string Name = "Name";
            public const string Lastname = "Lastname";
            public const string IdIDCard = "IdIDCard";
            public const string Photo = "Photo";
            public const string Notes = "Notes";
            public const string IdStatusCRUD = "IdStatusCRUD";

			static public string ToColumnName(string propertyName)
			{
				if(ht == null)
				{
					ht = new Hashtable();
					
					ht[IdPerson] = _Person.ColumnNames.IdPerson;
					ht[Name] = _Person.ColumnNames.Name;
					ht[Lastname] = _Person.ColumnNames.Lastname;
					ht[IdIDCard] = _Person.ColumnNames.IdIDCard;
					ht[Photo] = _Person.ColumnNames.Photo;
					ht[Notes] = _Person.ColumnNames.Notes;
					ht[IdStatusCRUD] = _Person.ColumnNames.IdStatusCRUD;

				}
				return (string)ht[propertyName];
			}

			static private Hashtable ht = null;			 
		}			 
		#endregion	

		#region StringPropertyNames
		public class StringPropertyNames
		{  
            public const string IdPerson = "s_IdPerson";
            public const string Name = "s_Name";
            public const string Lastname = "s_Lastname";
            public const string IdIDCard = "s_IdIDCard";
            public const string Notes = "s_Notes";
            public const string IdStatusCRUD = "s_IdStatusCRUD";

		}
		#endregion		
		
		#region Properties
	
		public virtual int IdPerson
	    {
			get
	        {
				return base.Getint(ColumnNames.IdPerson);
			}
			set
	        {
				base.Setint(ColumnNames.IdPerson, value);
			}
		}

		public virtual string Name
	    {
			get
	        {
				return base.Getstring(ColumnNames.Name);
			}
			set
	        {
				base.Setstring(ColumnNames.Name, value);
			}
		}

		public virtual string Lastname
	    {
			get
	        {
				return base.Getstring(ColumnNames.Lastname);
			}
			set
	        {
				base.Setstring(ColumnNames.Lastname, value);
			}
		}

		public virtual int IdIDCard
	    {
			get
	        {
				return base.Getint(ColumnNames.IdIDCard);
			}
			set
	        {
				base.Setint(ColumnNames.IdIDCard, value);
			}
		}

		public virtual byte[] Photo
	    {
			get
	        {
				return base.GetByteArray(ColumnNames.Photo);
			}
			set
	        {
				base.SetByteArray(ColumnNames.Photo, value);
			}
		}

		public virtual string Notes
	    {
			get
	        {
				return base.Getstring(ColumnNames.Notes);
			}
			set
	        {
				base.Setstring(ColumnNames.Notes, value);
			}
		}

		public virtual int IdStatusCRUD
	    {
			get
	        {
				return base.Getint(ColumnNames.IdStatusCRUD);
			}
			set
	        {
				base.Setint(ColumnNames.IdStatusCRUD, value);
			}
		}


		#endregion
		
		#region String Properties
	
		public virtual string s_IdPerson
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.IdPerson) ? string.Empty : base.GetintAsString(ColumnNames.IdPerson);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.IdPerson);
				else
					this.IdPerson = base.SetintAsString(ColumnNames.IdPerson, value);
			}
		}

		public virtual string s_Name
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.Name) ? string.Empty : base.GetstringAsString(ColumnNames.Name);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.Name);
				else
					this.Name = base.SetstringAsString(ColumnNames.Name, value);
			}
		}

		public virtual string s_Lastname
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.Lastname) ? string.Empty : base.GetstringAsString(ColumnNames.Lastname);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.Lastname);
				else
					this.Lastname = base.SetstringAsString(ColumnNames.Lastname, value);
			}
		}

		public virtual string s_IdIDCard
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.IdIDCard) ? string.Empty : base.GetintAsString(ColumnNames.IdIDCard);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.IdIDCard);
				else
					this.IdIDCard = base.SetintAsString(ColumnNames.IdIDCard, value);
			}
		}

		public virtual string s_Notes
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.Notes) ? string.Empty : base.GetstringAsString(ColumnNames.Notes);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.Notes);
				else
					this.Notes = base.SetstringAsString(ColumnNames.Notes, value);
			}
		}

		public virtual string s_IdStatusCRUD
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.IdStatusCRUD) ? string.Empty : base.GetintAsString(ColumnNames.IdStatusCRUD);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.IdStatusCRUD);
				else
					this.IdStatusCRUD = base.SetintAsString(ColumnNames.IdStatusCRUD, value);
			}
		}


		#endregion		
	
		#region Where Clause
		public class WhereClause
		{
			public WhereClause(BusinessEntity entity)
			{
				this._entity = entity;
			}
			
			public TearOffWhereParameter TearOff
			{
				get
				{
					if(_tearOff == null)
					{
						_tearOff = new TearOffWhereParameter(this);
					}

					return _tearOff;
				}
			}

			#region WhereParameter TearOff's
			public class TearOffWhereParameter
			{
				public TearOffWhereParameter(WhereClause clause)
				{
					this._clause = clause;
				}
				
				
				public WhereParameter IdPerson
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.IdPerson, Parameters.IdPerson);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter Name
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.Name, Parameters.Name);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter Lastname
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.Lastname, Parameters.Lastname);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter IdIDCard
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.IdIDCard, Parameters.IdIDCard);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter Photo
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.Photo, Parameters.Photo);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter Notes
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.Notes, Parameters.Notes);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter IdStatusCRUD
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.IdStatusCRUD, Parameters.IdStatusCRUD);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}


				private WhereClause _clause;
			}
			#endregion
		
			public WhereParameter IdPerson
		    {
				get
		        {
					if(_IdPerson_W == null)
	        	    {
						_IdPerson_W = TearOff.IdPerson;
					}
					return _IdPerson_W;
				}
			}

			public WhereParameter Name
		    {
				get
		        {
					if(_Name_W == null)
	        	    {
						_Name_W = TearOff.Name;
					}
					return _Name_W;
				}
			}

			public WhereParameter Lastname
		    {
				get
		        {
					if(_Lastname_W == null)
	        	    {
						_Lastname_W = TearOff.Lastname;
					}
					return _Lastname_W;
				}
			}

			public WhereParameter IdIDCard
		    {
				get
		        {
					if(_IdIDCard_W == null)
	        	    {
						_IdIDCard_W = TearOff.IdIDCard;
					}
					return _IdIDCard_W;
				}
			}

			public WhereParameter Photo
		    {
				get
		        {
					if(_Photo_W == null)
	        	    {
						_Photo_W = TearOff.Photo;
					}
					return _Photo_W;
				}
			}

			public WhereParameter Notes
		    {
				get
		        {
					if(_Notes_W == null)
	        	    {
						_Notes_W = TearOff.Notes;
					}
					return _Notes_W;
				}
			}

			public WhereParameter IdStatusCRUD
		    {
				get
		        {
					if(_IdStatusCRUD_W == null)
	        	    {
						_IdStatusCRUD_W = TearOff.IdStatusCRUD;
					}
					return _IdStatusCRUD_W;
				}
			}

			private WhereParameter _IdPerson_W = null;
			private WhereParameter _Name_W = null;
			private WhereParameter _Lastname_W = null;
			private WhereParameter _IdIDCard_W = null;
			private WhereParameter _Photo_W = null;
			private WhereParameter _Notes_W = null;
			private WhereParameter _IdStatusCRUD_W = null;

			public void WhereClauseReset()
			{
				_IdPerson_W = null;
				_Name_W = null;
				_Lastname_W = null;
				_IdIDCard_W = null;
				_Photo_W = null;
				_Notes_W = null;
				_IdStatusCRUD_W = null;

				this._entity.Query.FlushWhereParameters();

			}
	
			private BusinessEntity _entity;
			private TearOffWhereParameter _tearOff;
			
		}
	
		public WhereClause Where
		{
			get
			{
				if(_whereClause == null)
				{
					_whereClause = new WhereClause(this);
				}
		
				return _whereClause;
			}
		}
		
		private WhereClause _whereClause = null;	
		#endregion
	
		#region Aggregate Clause
		public class AggregateClause
		{
			public AggregateClause(BusinessEntity entity)
			{
				this._entity = entity;
			}
			
			public TearOffAggregateParameter TearOff
			{
				get
				{
					if(_tearOff == null)
					{
						_tearOff = new TearOffAggregateParameter(this);
					}

					return _tearOff;
				}
			}

			#region AggregateParameter TearOff's
			public class TearOffAggregateParameter
			{
				public TearOffAggregateParameter(AggregateClause clause)
				{
					this._clause = clause;
				}
				
				
				public AggregateParameter IdPerson
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.IdPerson, Parameters.IdPerson);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter Name
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.Name, Parameters.Name);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter Lastname
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.Lastname, Parameters.Lastname);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter IdIDCard
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.IdIDCard, Parameters.IdIDCard);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter Photo
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.Photo, Parameters.Photo);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter Notes
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.Notes, Parameters.Notes);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter IdStatusCRUD
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.IdStatusCRUD, Parameters.IdStatusCRUD);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}


				private AggregateClause _clause;
			}
			#endregion
		
			public AggregateParameter IdPerson
		    {
				get
		        {
					if(_IdPerson_W == null)
	        	    {
						_IdPerson_W = TearOff.IdPerson;
					}
					return _IdPerson_W;
				}
			}

			public AggregateParameter Name
		    {
				get
		        {
					if(_Name_W == null)
	        	    {
						_Name_W = TearOff.Name;
					}
					return _Name_W;
				}
			}

			public AggregateParameter Lastname
		    {
				get
		        {
					if(_Lastname_W == null)
	        	    {
						_Lastname_W = TearOff.Lastname;
					}
					return _Lastname_W;
				}
			}

			public AggregateParameter IdIDCard
		    {
				get
		        {
					if(_IdIDCard_W == null)
	        	    {
						_IdIDCard_W = TearOff.IdIDCard;
					}
					return _IdIDCard_W;
				}
			}

			public AggregateParameter Photo
		    {
				get
		        {
					if(_Photo_W == null)
	        	    {
						_Photo_W = TearOff.Photo;
					}
					return _Photo_W;
				}
			}

			public AggregateParameter Notes
		    {
				get
		        {
					if(_Notes_W == null)
	        	    {
						_Notes_W = TearOff.Notes;
					}
					return _Notes_W;
				}
			}

			public AggregateParameter IdStatusCRUD
		    {
				get
		        {
					if(_IdStatusCRUD_W == null)
	        	    {
						_IdStatusCRUD_W = TearOff.IdStatusCRUD;
					}
					return _IdStatusCRUD_W;
				}
			}

			private AggregateParameter _IdPerson_W = null;
			private AggregateParameter _Name_W = null;
			private AggregateParameter _Lastname_W = null;
			private AggregateParameter _IdIDCard_W = null;
			private AggregateParameter _Photo_W = null;
			private AggregateParameter _Notes_W = null;
			private AggregateParameter _IdStatusCRUD_W = null;

			public void AggregateClauseReset()
			{
				_IdPerson_W = null;
				_Name_W = null;
				_Lastname_W = null;
				_IdIDCard_W = null;
				_Photo_W = null;
				_Notes_W = null;
				_IdStatusCRUD_W = null;

				this._entity.Query.FlushAggregateParameters();

			}
	
			private BusinessEntity _entity;
			private TearOffAggregateParameter _tearOff;
			
		}
	
		public AggregateClause Aggregate
		{
			get
			{
				if(_aggregateClause == null)
				{
					_aggregateClause = new AggregateClause(this);
				}
		
				return _aggregateClause;
			}
		}
		
		private AggregateClause _aggregateClause = null;	
		#endregion
	
		protected override IDbCommand GetInsertCommand() 
		{
		
			SqlCommand cmd = new SqlCommand();
			cmd.CommandType = CommandType.StoredProcedure;
			cmd.CommandText = "[" + this.SchemaStoredProcedure + "proc_PersonInsert]";
	
			CreateParameters(cmd);
			
			SqlParameter p;
			p = cmd.Parameters[Parameters.IdPerson.ParameterName];
			p.Direction = ParameterDirection.Output;
    
			return cmd;
		}
	
		protected override IDbCommand GetUpdateCommand()
		{
		
			SqlCommand cmd = new SqlCommand();
			cmd.CommandType = CommandType.StoredProcedure;
			cmd.CommandText = "[" + this.SchemaStoredProcedure + "proc_PersonUpdate]";
	
			CreateParameters(cmd);
			      
			return cmd;
		}
	
		protected override IDbCommand GetDeleteCommand()
		{
		
			SqlCommand cmd = new SqlCommand();
			cmd.CommandType = CommandType.StoredProcedure;
			cmd.CommandText = "[" + this.SchemaStoredProcedure + "proc_PersonDelete]";
	
			SqlParameter p;
			p = cmd.Parameters.Add(Parameters.IdPerson);
			p.SourceColumn = ColumnNames.IdPerson;
			p.SourceVersion = DataRowVersion.Current;

  
			return cmd;
		}
		
		private IDbCommand CreateParameters(SqlCommand cmd)
		{
			SqlParameter p;
		
			p = cmd.Parameters.Add(Parameters.IdPerson);
			p.SourceColumn = ColumnNames.IdPerson;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.Name);
			p.SourceColumn = ColumnNames.Name;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.Lastname);
			p.SourceColumn = ColumnNames.Lastname;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.IdIDCard);
			p.SourceColumn = ColumnNames.IdIDCard;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.Photo);
			p.SourceColumn = ColumnNames.Photo;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.Notes);
			p.SourceColumn = ColumnNames.Notes;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.IdStatusCRUD);
			p.SourceColumn = ColumnNames.IdStatusCRUD;
			p.SourceVersion = DataRowVersion.Current;


			return cmd;
		}
	}
}
